package com.weiiew.itemservice.annotation;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Caching;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @Description
 * @Author 魏锴
 * @Date 2025/4/6
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Caching(evict = {
        @CacheEvict(cacheNames = "item:vo", key = "#id", condition = "id != null"),
        @CacheEvict(cacheNames = "item:one", key = "#id", condition = "id != null"),
        @CacheEvict(cacheNames = "item:list", key = "#version + '*'", cacheManager = "fuzzyCacheManager"),
        @CacheEvict(cacheNames = "item:list:simple", key = "#version + '*'", cacheManager = "fuzzyCacheManager"),
        @CacheEvict(cacheNames = "item:list:sizes", key = "#version"),
        @CacheEvict(cacheNames = "item:length", key = "#version + '*'", cacheManager = "fuzzyCacheManager"),
        @CacheEvict(cacheNames = "item:list:use", key = "#version"),
        @CacheEvict(cacheNames = "item:icons", key = "#version"),
        @CacheEvict(cacheNames = "cal:recipe:item", key = "#version + '*'", cacheManager = "fuzzyCacheManager"),
        @CacheEvict(cacheNames = "recipe:item:recipe:map", key = "#version"),
        @CacheEvict(cacheNames = "item:id:name:map", key = "#version"),
})
public @interface ItemChangeCacheEvict {
}
